package com.ruoyi.server.api.memberCoach.controller;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.server.api.memberCoach.domain.MemberCoach;
import com.ruoyi.server.api.memberCoach.model.MemberCoachAndCoachManagement;
import com.ruoyi.server.api.memberCoach.service.IMemberCoachService;
import org.apache.ibatis.annotations.Delete;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 会员用户教练关系Controller
 *
 * @author zmh
 * @date 2024-06-12
 */
@RestController
@RequestMapping("/member/memberCoach")
public class MemberCoachController extends BaseController
{
    @Autowired
    private IMemberCoachService memberCoachService;

    /**
     * 查询会员用户教练关系列表
     */
    @GetMapping("memberCoachById")
    public AjaxResult memberCoachById(Integer id,String venueUniqueIdentifier)
    {
        List<MemberCoachAndCoachManagement> memberCoach = memberCoachService.memberCoachById(id, venueUniqueIdentifier);
        return AjaxResult.success(memberCoach);
    }
    /**
    * @Author ZMH
    * @Description 续课
    * @Date 2024/6/13 19:05
    * @Return
    * @param memberCoach,venueUniqueIdentifier
    */
    @PutMapping("/addCourseTime")
    public AjaxResult addCourseTime(@RequestBody MemberCoach memberCoach){
        //获取教练id
        Integer courseId = memberCoach.getCoachId();
        //获取用户id
        Integer memberUserId = memberCoach.getMemberUserId();
        //获取课程时长
        Integer courseTime = memberCoach.getCourseTime();
        //获取唯一标识
        String venueUniqueIdentifier = memberCoach.getVenueUniqueIdentifier();
        int i = memberCoachService.addCourseTime(courseTime,courseId,memberUserId,venueUniqueIdentifier);
        return AjaxResult.success(i);
    }
    /**
     * @Author ZMH
     * @Description 退课程时长
     * @Date 2024/6/13 19:05
     * @Return
     * @param memberCoach,venueUniqueIdentifier
     */
//    @PutMapping("/refundCourseTime")
//    public AjaxResult refundCourseTime(@RequestBody MemberCoach memberCoach){
//        //获取教练id
//        Integer courseId = memberCoach.getCoachId();
//        //获取用户id
//        Integer memberUserId = memberCoach.getMemberUserId();
//        //获取课程时长
//        Integer courseTime = memberCoach.getCourseTime();
//        //获取唯一标识
//        String venueUniqueIdentifier = memberCoach.getVenueUniqueIdentifier();
//        int i = memberCoachService.refundCourseTime(courseTime,courseId,memberUserId,venueUniqueIdentifier);
//        return AjaxResult.success(i);
//    }
}
